class Solution
{
public:
    int findMin(vector<int> &nums)
    {
        int left = 0;
        int right = nums.size();
        while (right > 0 && nums[right - 1] == nums[0])
        {
            --right;
        }
        while (left < right)
        {
            int mid = (left + right) / 2;
            if (nums[mid] >= nums[0])
            {
                left = mid + 1;
            }
            else
            {
                right = mid;
            }
        }
        return nums[left % nums.size()];
    }
};